﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace NORM.Demo
{
    public partial class SQL超时执行 : Form
    {
        public SQL超时执行()
        {
            InitializeComponent();
        }

        private void dd()
        {
            DateTime stime = DateTime.Now;
            label3.Text = stime.ToString("yyyy-MM-dd HH:mm:ss.fff");
            try
            {
                string connectionString = "Server=192.168.0.116;Initial Catalog=CMSMonitordataGL_明阳大黑山;User ID=sa;Pwd=YHPych920,.;";
                using (var db = NORM.DataBase.DataBaseFactory.Create(connectionString, NORM.DataBase.DataBaseTypes.SqlDataBase))
                {
                    string sql = "UPDATE  [CMSMonitordataGL_明阳大黑山].[dbo].[WaveData_3] SET IsExport='true' WHERE NodeID=6 and DateTime='2017-05-17 11:04:07.000' ";
                    db.Execute(CommandType.Text, sql, 5 * 60, null);

                    var list = NORM.SQLObject.EntityQuery<Models.T_Login>.Instance.QueryToList("select * from T_Login ", db);

                    //db.Execute(CommandType.Text, sql, null);
                    DateTime etime = DateTime.Now;
                    label4.Text = etime.ToString("yyyy-MM-dd HH:mm:ss.fff");
                    label6.Text = ((etime - stime).Milliseconds * 1.0 / 1000) + " 秒";
                    MessageBox.Show("成功");
                }
            }
            catch (Exception ex)
            {
                DateTime etime = DateTime.Now;
                label4.Text = etime.ToString("yyyy-MM-dd HH:mm:ss.fff");
                label6.Text = ((etime - stime).TotalMilliseconds * 1.0 / 1000) + " 秒";
                MessageBox.Show(ex.Message);
            }
        }

        private void dd2()
        {
            DateTime stime = DateTime.Now;
            label3.Text = stime.ToString("yyyy-MM-dd HH:mm:ss.fff");
            try
            {
                string connectionString = "Server=(Local);Initial Catalog=IBatisNet;User ID=sa;Pwd=123456;";
                using (var db = NORM.DataBase.DataBaseFactory.Create(connectionString, NORM.DataBase.DataBaseTypes.SqlDataBase))
                {
                    var dt = db.GetTableObject("Accounts");
                }
            }
            catch (Exception ex)
            {
                DateTime etime = DateTime.Now;
                label4.Text = etime.ToString("yyyy-MM-dd HH:mm:ss.fff");
                label6.Text = ((etime - stime).TotalMilliseconds * 1.0 / 1000) + " 秒";
                MessageBox.Show(ex.Message);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            dd2();
        }
    }
}
